var idCuponToValidate = 0;

function openDialog (id, name) {
  idCuponToValidate = id;
  $(this).simpledialog2({
    mode: 'button',
      headerText: 'Etes vous sur de valider de ' + name,
      headerClose: true,
      dialogForce: true,
      buttonPrompt: 'Please Choose One',
      buttons : {
        'OK': {
          click: function () { 
	          var form = $("<form></form>");
	          form.attr('method', 'POST');
	          form.attr('action', '/cuponManager');
	          form.attr('id', 'formCuponTovalidate');
	          form.css('display', 'none');
	          form.append(input('id', idCuponToValidate));
	          form.append(input('action', 'validate'));
	          $('#content').append(form); 
	          $('#formCuponTovalidate').submit();
          }
        },
        'Cancel': {
          click: function () { 
            $('#buttonoutput').text('Cancel');
          },
          icon: "delete",
          theme: "c"
        }
      }
    
    })
}

function input(name, value) {
	var input = $("<input>").attr('type', 'text');
	input.attr('name', name);
	input.val(value);
	return input;
}